<include file="Public/header" />
    <div class="wrapper wrapper-content animated fadeInRight">

            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>
                             权限分配
                             </h5>

                            <div class="ibox-tools">
                                <a class="collapse-link" href="/admin/rbac/index/groupid/{$_GET['groupid']}">
                                    <i class="fa fa-chevron-up"></i>返回角色管理
                                </a>
                 
                            </div>
                        </div>
                        <div class="ibox-content">
                        <form action="{:U('Ajax/Rbac/add')}" method="post" class="cmzForm">
                        <div style="border:1px dotted #DDD;padding:5px;">
                          <p class="label label-danger " style="border 1px solid ">模块化分类和数据授权</p>  
                        </div>
                        <!-- ======================模块化分类和模块化数据菜单权限配置================ -->
                        <?php foreach ($mkfMeun as $key => $v): ?>
                            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="8">
                                <thead>
                                <tr>
                                    <th>
                                    {$v.name}  
                                    <a href="javascript:;" data-id="{$v.id}" class="mkfMenu_all" checked="checked">全选</a>/
                                    <a href="javascript:;" data-id="{$v.id}" class="reverse_all">反选</a>
                                    |||
                                    <a href="javascript:;" data-id="{$v.id}" class="mkfMenu_all_func" checked="checked">全选所有</a>/
                                    <a href="javascript:;" data-id="{$v.id}" class="reverse_all_func">反选所有</a>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                
                                <tr>
                                    <td>
                                        <?php foreach ($v['children'] as $kc => $vc): ?>

    										<div class="pull-left mkfMenu_area{$v.id}" style="width:550px;">
    					                        <div class="timeline-item">
    					                            <div class="">
    					                                <div class="col-xs-3 date">
    					                                    <i class="fa">
                                                            <input data-parentid="{$vc.parentid}" class="mkfMenu{$v.id}" type="checkbox" <?php if($vc['checked']){ echo "checked = 'checked'";} ?> name="mkf[{$vc.id}-{$vc.mkf_id}][list]" value="{$vc.id}-{$vc.mkf_id}">
                                                            </i> 
    					                                </div>
    					                                <div class="col-xs-8 content no-top-border" style="min-height:10px;">
    					                                    <p class="m-b-xs pull-left" style="min-width:135px;">
                                                                 <strong>{$vc.name}</strong><a href="javascript:;" class="re_sele_child">反选</a>
    					                                    </p>
                                                            <p class="m-b-xs pull-left" style="margin-left:20px;">
                                                                分类【
                                                                <?php foreach ($vc['cat'] as $kb => $vb): ?>
                                                                    <span>
                                                                    <input type="checkbox" class="mkf " <?php if($vb['status']=="checked"){ echo "checked = 'checked'";} ?> name="mkf[{$vc.id}-{$vc.mkf_id}][cat][]" value="{$kb}">{$vb.name}
                                                                    </span>
                                                                <?php endforeach ?>】
                                                                <br/>
                                                                 数据【
                                                                <?php foreach ($vc['post'] as $kb => $vb): ?>
                                                                    <span>
                                                                    <input type="checkbox" class="mkf " <?php if($vb['status']=="checked"){ echo "checked = 'checked'";} ?> name="mkf[{$vc.id}-{$vc.mkf_id}][post][]" value="{$kb}">{$vb.name}
                                                                    </span>
                                                                <?php endforeach ?>】
                                                            </p>
    					                                </div>
    					                            </div>
    					                        </div>
    					                    </div>
    					                <?php endforeach ?>
                                    </td>
                                </tr>
                            
                                </tbody>
                               
                            </table>
                        <?php endforeach ?>
						<div style="border:1px dotted #DDD;padding:5px;">
                          <p class="label label-danger " style="border 1px solid ">附加菜单</p>  
                        </div>
                        
                       
                        <!-- //======================后台的菜单权限配置================ -->
                         <?php foreach ($extraMenu as $key => $v): ?>
                            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="8">
                                <thead>
                                <tr>
                                    <th>
                                    {$v.name}  
                                    <a href="javascript:;" data-id="{$v.id}" class="select_all">全选</a>/
                                    <a href="javascript:;" data-id="{$v.id}" class="reverse_select">反选</a>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                
                                <tr>
                                    <td>
                                        <?php foreach ($v['children'] as $kc => $vc): ?>
                                            <div class="pull-left" style="width:350px;">
                                                <div class="timeline-item">
                                                    <div class="">
                                                        <div class="col-xs-3 date">
                                                            <i class="fa"><input data-parentid="{$v.id}" type="checkbox"  <?php if($vc['checked']){ echo "checked = 'checked'";} ?> name="power[]" value="{$vc.url}"></i> 
                                                        </div>
                                                        <div class="col-xs-5 content no-top-border" style="min-height:10px;">
                                                            <p class="m-b-xs"><strong>{$vc.name} </strong>
                                                            </p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        <?php endforeach ?>
                                    </td>
                                </tr>
                            
                                </tbody>
                               
                            </table>
                        <?php endforeach ?>
                        <div style="border:1px dotted #DDD;padding:5px;">
                          <p class="label label-danger " style="border 1px solid ">后台菜单</p>  
                        </div>
                    <!-- //======================附加自定义的菜单权限配置================ -->
                         <?php foreach ($adminMenu as $key => $v): ?>
                            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="8">
                                <thead>
                                <tr>
                                    <th>
                                    {$v.name}  
                                    <a href="javascript:;" data-id="{$v.id}" class="select_all">全选</a>/
                                    <a href="javascript:;" data-id="{$v.id}" class="reverse_select">反选</a>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                
                                <tr>
                                    <td>
                                        <?php foreach ($v['children'] as $kc => $vc): ?>
                                            <div class="pull-left" style="width:350px;">
                                                <div class="timeline-item">
                                                    <div class="">
                                                        <div class="col-xs-3 date">
                                                            <i class="fa"><input data-parentid="{$v.id}" type="checkbox"  <?php if($vc['checked']){ echo "checked = 'checked'";} ?> name="power[]" value="{$vc.url}"></i> 
                                                        </div>
                                                        <div class="col-xs-5 content no-top-border" style="min-height:10px;">
                                                            <p class="m-b-xs"><strong>{$vc.name} </strong>
                                                            </p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        <?php endforeach ?>
                                    </td>
                                </tr>
                            
                                </tbody>
                               
                            </table>
                        <?php endforeach ?>


						<input type="hidden" name="id" value="{$id}">
						<a class="btn btn-primary  btn-outline cmzPost" table="role_access">授权</a>
                        </div>
                    </div>
                </div>
            </div>
            
        </div>
        <script type="text/javascript">
        //模块化全选  S
        $(".mkfMenu_all").click(function(event) {
            var dataid = $(this).attr('data-id');
            for (var i = 0; i < $(".mkfMenu"+dataid).length; i++) {
                $(".mkfMenu"+dataid).eq(i).prop("checked", true);
            };
           
        });
        $(".reverse_all").click(function(event) {
             var dataid = $(this).attr('data-id');
                for (var i = 0; i < $(".mkfMenu"+dataid).length; i++) {
                    // alert($(".mkfMenu"+dataid).eq(i).prop("checked"))
                     if($(".mkfMenu"+dataid).eq(i).prop("checked") == true){
                        $(".mkfMenu"+dataid).eq(i).prop("checked", false);
                        // console.log(1);
                    }else{
                        $(".mkfMenu"+dataid).eq(i).prop("checked", true);
                        // console.log(2);
                    }
                };
        });
          $(".mkfMenu_all_func").click(function(event) {
            var dataid = $(this).attr('data-id');
            var choose = $(".mkfMenu_area"+dataid).find("input");
            // alert(choose.length);
            for (var i = 0; i < $(".mkfMenu_area"+dataid).find("input").length; i++) {
                choose.eq(i).prop("checked", true);
            };
           
        });
        $(".reverse_all_func").click(function(event) {
             var dataid = $(this).attr('data-id');
             var choose = $(".mkfMenu_area"+dataid).find("input");
                for (var i = 0; i < choose.length; i++) {
                    // alert($(".mkfMenu"+dataid).eq(i).prop("checked"))
                     if(choose.eq(i).prop("checked") == true){
                        choose.eq(i).prop("checked", false);
                        // console.log(1);{
                    }else{
                        choose.eq(i).prop("checked", true);
                        // console.log(2);
                    }
                };
        });
        //模块化下面的操作按钮
          $('.re_sele_child').click(function(event) {
            var choose = $(this).parent('p').siblings('p').find('input');
            for (var i = 0; i < choose.length; i++) {
                     if(choose.eq(i).prop("checked") == true){
                        choose.eq(i).prop("checked", false);
                    }else{
                        choose.eq(i).prop("checked", true);
                    }
                };
            //按钮选择了，当然列表也要选择，不然无法显示按钮的位置
            $(this).parents('div.content').siblings('.data').find("input").prop("checked", true);

        });

        //模块化全选  E
        $(".select_all").click(function(event) {
           var dataid = $(this).attr('data-id');
            var choose = $("input[data-parentid="+dataid+"]");
           for (var i = 0; i < choose.length; i++) {
                choose.eq(i).prop("checked", true);
            };
        });

      

        $('.reverse_select').click(function(event) {
           var dataid = $(this).attr('data-id');
            var choose = $("input[data-parentid="+dataid+"]");
             for (var i = 0; i < choose.length; i++) {
                    // alert($(".mkfMenu"+dataid).eq(i).prop("checked"))
                     if(choose.eq(i).prop("checked") == true){
                        choose.eq(i).prop("checked", false);
                        // console.log(1);{
                    }else{
                        choose.eq(i).prop("checked", true);
                        // console.log(2);
                    }
                };
        });


        // $('.mkf').click(function(event) {
        //     if($(this).parent().find('input').prop("checked")!=true){
        //         $(this).parent().find('input').prop("checked",true)
        //     }
        // });


        </script>
</form>




